---
title: 'debug | Cypress Documentation'
description: Set a `debugger` in Cypress and log what the previous command yields.
sidebar_label: debug
slug: /api/commands/debug
---

<ProductHeading product="app" />

# debug

Set a `debugger` and log what the previous command yields.

:::caution

You need to have your Developer Tools open for `.debug()` to hit the breakpoint.

:::

## Syntax

```javascript
.debug()
.debug(options)

// ---or---

cy.debug()
cy.debug(options)
```

### Usage

<Icon name="check-circle" color="green" /> **Correct Usage**

```javascript
cy.debug().getCookie('app') // Pause to debug at beginning of commands
cy.get('nav').debug() // Debug the `get` command's yield
```

### Arguments

<Icon name="angle-right" /> **options _(Object)_**

Pass in an options object to change the default behavior of `.debug()`.

| Option | Default | Description                                                                         |
| ------ | ------- | ----------------------------------------------------------------------------------- |
| `log`  | `true`  | Displays the command in the [Command log](/app/core-concepts/open-mode#Command-Log) |

<HeaderYields />

- `.debug()` yields the same subject it was given from the previous command.
- `.debug()` is a query, and it is _safe_ to chain further commands.

## Examples

### Debug

#### Pause with debugger after `.get()`

```javascript
cy.get('a').debug().should('have.attr', 'href')
```

## Rules

<HeaderRequirements />

- `.debug()` can be chained off of `cy` or off another command.

<HeaderAssertions />

- `.debug()` is a utility command.
- `.debug()` will not run assertions. Assertions will pass through as if this
  command did not exist.

<HeaderTimeouts />

- `.debug()` cannot time out.

## Command Log

**_Log out the current subject for debugging_**

```javascript
cy.get('.ls-btn').click({ force: true }).debug()
```

The commands above will display in the Command Log as:

<DocsImage
  src="/img/api/debug/how-debug-displays-in-command-log.png"
  alt="Command Log debug"
/>

When clicking on the `debug` command within the command log, the console outputs
the following:

<DocsImage
  src="/img/api/debug/console-gives-all-debug-info-for-command.png"
  alt="console.log debug"
/>

## See also

- [Cypress Cloud](https://on.cypress.io/cloud)
- [`.pause()`](/api/commands/pause)
- [`cy.log()`](/api/commands/log)
- [`cy.screenshot()`](/api/commands/screenshot)
